import {createStore} from "vuex";
export default createStore({
    state: {
        loggedUser: {
            id: '',
            userName: '',
            userRole: '',
        },
        isLogin: false
    },
    mutations: {
        // 更新当前登录用户信息
        updateUser(state,userInfo) {
            state.loggedUser.id = userInfo.id;
            state.loggedUser.userName = userInfo.userName;
            state.loggedUser.userRole = userInfo.userRole;
            window.localStorage.setItem("loggedUser",JSON.stringify(state.loggedUser));
        },
        // 清空当前登录用户信息
        cleanUser(state) {
            state.loggedUser.id = '';
            state.loggedUser.userName = '';
            state.loggedUser.userRole = '';
            window.localStorage.setItem("loggedUser",JSON.stringify(state.loggedUser));
        }
    },
    actions: {

    },
    modules: {

    }
})